package com.un.ebs.production.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.un.ebs.core.enums.BooleanEnum;
import com.un.ebs.production.domain.*;
import com.un.ebs.production.dto.*;
import com.un.ebs.purchase.dto.PurchaseItemCreateDto;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author liubo
 * @since 2020-05-25
 */
public interface ProductionOrderService {

    String add(ProductionOrderAddDto req);

    String addReBuild(ProductionOrderRebuildDto req);

    String add(ProductionOrderAddBySaleDto req);

    void update(ProductionOrderUpdateDto req);

    void delete(String id);

    void submit(String id);

    void submitCancel(String id);

    void run(String id, String seqId);

    /**
     * 修复已开工，但是没有创建工单的问题
     *
     * @param code
     */
    void runFix(String code);

    String runServicePurchaseFix(String code);

    /**
     * 完工了且未收货、未出库处理
     *
     * @param code
     * @return
     */
    String runServicesNotAcceptFix(String code);

    /**
     * 完工了，已收货，未出库，补全出库
     *
     * @param code
     * @return
     */
    String runServicesOutFix(String code);

    void runCancel(String id);

    void deliver(String id);

    void productionToPurchaseOrder(List<PurchaseItemCreateDto> objs);

    void productionToPurchaseContract(List<PurchaseItemCreateDto> objs);

    void productionToBomUser(String productionOrderId, String warehouseId);

    void productionToBomUser(String productionOrderId, String warehouseId, String skuId, Double qty);

    void productionToBomUser(ProductionOrderToBomUserDto req);

    ProductionOrder queryById(String id);

    IPage<ProductionOrderExt> queryBySaleOrderId(String id, Integer pageSize, Integer pageIndex);

    List<ProductionOrderItem> queryItemById(String id);

    ProductionOrderItemExt queryItemByItemId(String itemId);

    IPage<ProductionOrderItemExt> queryItemById(String id, Integer pageSize, Integer pageIndex);

    IPage<ProductionOrderItemExt> queryItem(String searchText, BooleanEnum runStatus, BooleanEnum isComplete, Integer pageSize, Integer pageIndex);

    IPage<ProductionOrderItemBomExt> queryItemBom(String productionOrderId, BooleanEnum lackStatus, String skuId, Integer pageSize, Integer pageIndex);

    IPage<ProductionOrderItemBomSumExt> queryItemBomSum(String searchText, String productionOrderId, Integer pageSize, Integer pageIndex);

    ProductionOrderVo queryViewById(String id);

    ProductionOrderView queryViewByOrderId(String id);

    IPage<ProductionOrderExt> query(String searchText, BooleanEnum runStatus, BooleanEnum isComplete, Integer pageSize, Integer pageIndex);

    IPage<ProductionOrderRequirementPlanExt> queryRequirementItem(String searchText, String id, Integer pageSize, Integer pageIndex);

    IPage<ProductionRequirementPlanExt> queryRequirement(String searchText, String supplierEntId, Integer pageSize, Integer pageIndex);

    List<ProductionWorkOrderOutExt> queryItemBySeqSku(String productionOrderItemId);

    /**
     * 根据生产订单，查询所有委外工序订单
     *
     * @param productionOrderId
     * @return
     */
    List<ProductionWorkOrderOutExt> queryItemSeqSkuByOrderId(String productionOrderId);

    IPage<ProductionOrderView> queryView(String searchText, BooleanEnum runStatus, BooleanEnum isComplete, Integer pageSize, Integer pageIndex);

    IPage<ProductionOrderView> queryViewBySaleOrderId(String saleOrderId, Integer pageSize, Integer pageIndex);

    IPage<ProductionOrderView> queryViewByCanInInventory(String searchText, Integer pageSize, Integer pageIndex);

    IPage<ProductionCostDiffExt> queryCostMoneyDiff(String startMonth, String endMonth, Integer pageSize, Integer pageIndex);
}
